import {
  createRouter,
  createWebHashHistory,
  createWebHistory
} from 'vue-router'

const routes = [{
  path: '/menu',
  name: 'menu',
  component: () => import('../views/menu.vue'),
}, {
  path: '/base',
  name: 'base',
  component: () => import('../views/basePage.vue'),


  children: [{ //首页
    path: '/',
    name: 'home',
    component: () => import('../views/homeView.vue'),
    meta: {
      // pos: 4
    }
  }, { //环境信息
    path: '/environmentalInfo',
    name: 'environmentalInfo',
    component: () => import('../views/environmentalInfo.vue'),
    meta: {
      pos: 0
    }
  }, { //畜产品价格
    path: '/animalPrice',
    name: 'animalPrice',
    component: () => import('../views/animalPrice.vue'),
    meta: {
      pos: 6
    }
  }, { //技术服务
    path: '/technology',
    name: 'technology',
    component: () => import('../views/technologyView.vue'),
    meta: {
      pos: 7
    }
  }, { //视频监控
    path: '/monitor',
    name: 'monitor',
    component: () => import('../views/monitorView.vue'),
    meta: {
      pos: 1
    }
  }, { //预警信息
    path: '/warning',
    name: 'warning',
    component: () => import('../views/warningView.vue'),
    meta: {
      pos: 5
    }
  }, { //主推技术
    path: '/primaryTechnology',
    name: 'primaryTechnology',
    component: () => import('../views/primaryTechnology.vue'),
    meta: {
      pos: 8
    }
  }, { //粮种信息
    path: '/grainSeedMessage',
    name: 'grainSeedMessage',
    component: () => import('../views/grainSeedMessage.vue'),
    meta: {
      pos: 4
    }
  }, { //粪肥管理
    path: '/manureManagement',
    name: 'manureManagement',
    component: () => import('../views/manureManagement.vue'),
    meta: {
      pos: 2
    }
  }, { //微生物
    path: '/microorganism',
    name: 'microorganism',
    component: () => import('../views/microorganism.vue'),
    meta: {
      pos: 3
    }
  },{ //微生物-噬菌体
    path: '/microorganismPhage',
    name: 'microorganismPhage',
    component: () => import('../views/microorganismPhage.vue'),
    meta: {
      pos: 3
    }
  },{ //微生物-耐药菌
    path: '/microorganismResistant',
    name: 'microorganismResistant',
    component: () => import('../views/microorganismResistant.vue'),
    meta: {
      pos: 3
    }
  }, {
    path: '/setbase',
    name: 'setbase',
    component: () => import('../views/setup/setbase.vue'),
    children: [{ //设置中心-详情
      path: '/baseInfo',
      name: 'baseInfo',
      component: () => import('../views/setup/baseInfo.vue'),
      meta: {
        spos: 1
      }
    }, { //设置中心-详情-人员信息
      path: '/userInfo',
      name: 'userInfo',
      component: () => import('../views/setup/userInfo.vue'),
      meta: {
        spos: 2
      }
    }, { //设置中心-详情-人员信息-新建编辑
      path: '/userInfoEdit',
      name: 'userInfoEdit',
      component: () => import('../views/setup/userInfoEdit.vue'),
      meta: {
        spos: 2
      }
    }, { //设置中心-详情-摄像头信息
      path: '/cameraInfo',
      name: 'cameraInfo',
      component: () => import('../views/setup/cameraInfo.vue'),
      meta: {
        spos: 3
      }
    }, { //设置中心-详情-设备头信息
      path: '/deviceInfo',
      name: 'deviceInfo',
      component: () => import('../views/setup/deviceInfo.vue'),
      meta: {
        spos: 4
      }
    }, { //设置中心-详情-预警信息
      path: '/warningInfo',
      name: 'warningInfo',
      component: () => import('../views/setup/warningInfo.vue'),
      meta: {
        spos: 5
      }
    }],

  }, { //设置中心-养殖场管理
    path: '/farmManagement',
    name: 'farmManagement',
    component: () => import('../views/setup/farmManagement.vue'),
    meta: {}
  }, { //设置中心-人员管理
    path: '/personManagement',
    name: 'personManagement',
    component: () => import('../views/setup/personManagement.vue'),
    meta: {}
  }]
}, { //登录
  path: '/login',
  name: 'login',
  component: () => import('../views/login.vue')

}]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  scrollBehavior(to, from, savedPosition) {
    // 滚动到顶部
    return {
      top: 0
    }
  }
})

export default router